# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


class CsdncoursePipeline(object):
    def process_item(self, item, spider):
        print("长度长度" + str(len(item["name"])))
        print(item["name"])
        print(item["studentNum"])
        print(item["price"])
        print(item["courseNum"])
        file = open("C:/Users/admin/Desktop/csdnCourse/" + str(item["index"]) + ".text","w",encoding="utf-8")
        file.write("课程名："+item["name"]+'\n'+"学生数："+item["studentNum"]+'\n'+"课程价格"+item["price"].strip()+'\n'+"课程数：" + item["courseNum"])
        file.close()
        return item
